package com.jinghua.treatment.service.impl;

import com.jinghua.treatment.common.exception.BizException;
import com.jinghua.treatment.entity.SysDoctor;
import com.jinghua.treatment.entity.vo.ChineseMedicalVO;
import com.jinghua.treatment.mapper.SysChineseMedicalMapper;
import com.jinghua.treatment.service.ChineseMedicalService;
import com.jinghua.treatment.service.SysDoctorService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ChineseMedicalServiceImpl implements ChineseMedicalService {

    @Resource
    SysChineseMedicalMapper sysChineseMedicalMapper;
    @Resource
    SysDoctorService sysDoctorService;

    @Override
    public List searchMedical(String key,Integer doctorId) {
        //查询前检查 改医生的地区设置情况
        SysDoctor sysDoctor = sysDoctorService.findById(doctorId);
        if(sysDoctor!=null){
           String chargeAreaCode =  sysDoctor.getChargeAreaCode();
           if(chargeAreaCode == null)
               throw new BizException("医生收费区域未设置");

          return sysChineseMedicalMapper.searchMedicalWithAreaCode(key,chargeAreaCode);
        }
        return null;
    }
}
